package cn.declare.controller;

import cn.declare.bean.Performance;
import cn.declare.service.PerformanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * author：皇甫
 */
@RestController("/performance")
public class PerformanceController {
    @Autowired
    private PerformanceService performanceService;

    /**
     * 查询所有经营状况
     * @return
     */
    @RequestMapping("/getPerformanceList")
    public List<Performance> getPerformanceList(){
        List<Performance> list = performanceService.getPerformanceList();
        return list;
    }

    /**
     * 修改
     * @param performance
     * @return
     */
    @RequestMapping("/updatePerformance")
    public String updatePerformance(@RequestBody Performance performance){
        List<Performance> list = performanceService.getPerformanceList();
        if (list != null) {
            int i = performanceService.updatePerformance(performance);
            if (i>0){
                return "修改成功";
            }else {
                return "修改失败";
            }
        }else {
            return "没有修改！";
        }
    }
}
